exports.Createlogin= function(_args) {
	
	
    var pathimage=Ti.App.Properties.getString('pathimage');
	
	
	var platformWidth=Titanium.Platform.displayCaps.platformWidth;//Ti.App.Properties.getInt('platformWidth');
	var platformHeight=Titanium.Platform.displayCaps.platformHeight;//Ti.App.Properties.getInt('platformHeight');
	
	//Ti.API.info(platformWidth)
	Ti.API.info(platformHeight)
	var btnumber_width=Ti.App.Properties.getInt('MainWindow_btnumber_width')
	var btnumber_height=Ti.App.Properties.getInt('MainWindow_btnumber_height')
	
	var bottom_bt=Ti.App.Properties.getInt('MainWindow_bottom_bt')
	var right_bt=Ti.App.Properties.getInt('MainWindow_right_bt')
	var space=Ti.App.Properties.getInt('MainWindow_space')
	var bottom_row1=bottom_bt;
	var bottom_row2=bottom_bt+btnumber_height+space;
	var bottom_row3=bottom_bt+2*btnumber_height+2*space;
	var bottom_row4=bottom_bt+3*btnumber_height+3*space;
	
	var right_col1=right_bt;
	var right_col2=right_bt+btnumber_width+space;
	var right_col3=right_bt+2*btnumber_width+2*space;

	
	
	var bts=[
		{title:'VÀO',value:-1,func:'',bottom:bottom_row1,right:right_col1},
		{title:0,value:0,func:'',     bottom:bottom_row1,right:right_col2},
		{title:'XÓA',value:-2,func:'',bottom:bottom_row1,right:right_col3},
		{title:9,value:9,func:'',	  bottom:bottom_row2,right:right_col1},
		{title:8,value:8,func:'',     bottom:bottom_row2,right:right_col2},
		{title:7,value:7,func:'',     bottom:bottom_row2,right:right_col3},
		{title:6,value:6,func:'',     bottom:bottom_row3,right:right_col1},
		{title:5,value:5,func:'',     bottom:bottom_row3,right:right_col2},
		{title:4,value:4,func:'',     bottom:bottom_row3,right:right_col3},
		{title:3,value:3,func:'',     bottom:bottom_row4,right:right_col1},
		{title:2,value:2,func:'',     bottom:bottom_row4,right:right_col2},
		{title:1,value:1,func:'',     bottom:bottom_row4,right:right_col3},
		
	]
	
	
	var win = Ti.UI.createView({
	   
	    top: _args.top,
	    height:bottom_bt+5*btnumber_height+5*space,
	    width:'100%',
	    touchEnabled: true,
	    backgroundImage: pathimage+'panel_right.png',
	});
	
	var txtpassword = Titanium.UI.createTextField({
		
		     
		borderStyle: Ti.UI.INPUT_BORDERSTYLE_ROUNDED,
		passwordMask:true,
		enabled:false,
	    keyboardType: Titanium.UI.KEYBOARD_DEFAULT,
	    returnKeyType: Titanium.UI.RETURNKEY_SEARCH , 
		textAlign:'center',
		hintText:'NHẬP MẬT MÃ',
		right:right_bt,
		bottom:bottom_bt+4*btnumber_height+4*space,
		height:90,
		width:right_bt+3*btnumber_width+space,
	 	font:{
			fontSize:Ti.App.Properties.getInt('MainWindow_btnumber_fontsize'),
			fontWeight:'bold',
		 },
	}); 
	/*
	txtpassword.addEventListener('change', function (e) {
			Ti.API.info(txtpassword.value+e.value)
        	txtpassword.value=txtpassword.value+e.value
    })
    */
	win.add(txtpassword)
	
	
	
	var panel_left = Titanium.UI.createView({
		width:470,
		height:bottom_bt+5*btnumber_height+4*space,//340,
		left:20,
		backgroundImage:pathimage+'LehuyPos.png',
	}); 
	win.add(panel_left)
	var checkLogin = function (password) {
		var re=0
		if(password=='2013')
			re=1;
		return re;
	}
	var createButtonNumber = function (bt) {
		var bt = Titanium.UI.createButton({
		 	 borderColor: '#c0c0c0',
		     borderRadius: 10,
		     borderWidth:4,
			 title:bt.title,
			 value:bt.value,
			 backgroundImage:pathimage+'bt_Green.png',
			 backgroundSelectedImage:pathimage+'table.png',//pathimage+'bt_Green_press.png',
			 width:btnumber_width,
			 height:btnumber_height,
		   	 bottom:bt.bottom,
		   	 right:bt.right,
	   	 	 font:{
				fontSize:Ti.App.Properties.getInt('MainWindow_btnumber_fontsize'),
				fontWeight:'bold',
			 },
		}); 
		bt.addEventListener('click', function (e) {
			//Ti.API.info(e.source.value)
			require('settings').ClickSound();
			if(e.source.value===-1)//VÀO
			{
				//txtpassword.value='';
				if(checkLogin(txtpassword.value)==1)
				{
					//txtpassword.value='';
					Ti.App.fireEvent('MainWindow:login');
				}
	            	
            	else
            	{
            		txtpassword.value='';
            		require('settings').createAlertDialog(Ti.App.Properties.getString('title'),'Mật khẩu không chính xác !');
            	}
			}
				
			else if(e.source.value===-2)//XÓA
				txtpassword.value='';
			else
        		txtpassword.value=txtpassword.value+e.source.title
        })
		return bt;
	}
	
	for (i = 0; i < bts.length; i++){
        var btadd=createButtonNumber(bts[i])
        if(btadd.value===-1)//VÀO
        {
        	 btadd.backgroundImage=pathimage+'bt_oranges.png';
			 btadd.backgroundSelectedImage=pathimage+'table.png';//pathimage+'bt_oranges_press.png';
        }
		win.add(btadd);
    }
	
	return win;
};